home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / tbasmhlp.arc / SOURCE.ARC / FINDFILE.ASM < prev    next >
Assembly Source File  |  1987-07-21  |  964b  |  35 lines

  1. ;FILE    :FINDFILE.ASM
  2. ;USEAGE    :call FINDFILE("Pathname<wildcards optional>"+CHR$(0),search%,exist%)
  3. ;Search% is the file attribute byte used in search
  4. ;RETURNS:Exist=-1 if file does exist, 0 if it does not.
  5. findfile segment
  6. assume    cs:findfile
  7.     push    bp        ;Standard stuff.
  8.     mov    bp,sp
  9.     push    ds
  10.  
  11.     mov    dx,ds:[0]    ;Current string segment.
  12.     push    dx
  13.     pop    ds        ;THERE! String's segment is ds.
  14.  
  15.     les    di,[bp+0eh]    ;String descripter's pointer
  16.     mov    dx,es:[di+2]    ;offset of string in DS seg.
  17.  
  18.     les    di,[bp+0ah]    ;Pointer to Search%
  19.     mov    cx,es:[di]    ;Value of search%
  20.  
  21.     mov    ah,04eh        ;Request Find First/Matching
  22.     xor    si,si        ;Let's use SI for return value 0=not found
  23.     int    021h        ;Involk MSDOS
  24.  
  25.     jb    notfnd        ;Jump if there was a problem finding a match
  26.     dec    si        ;Found file, make it true(-1)
  27. notfnd:    les    di,[bp+06h]    ;Pointer to result integer exist%
  28.     mov    es:[di],si    ;store value into exist%
  29.  
  30.     pop    ds        ;Restore DS
  31.     pop    bp        ;Restore BP
  32. findfile ends
  33.     end
  34.     
  35.